//package org.batatasframework.support.attribute;
//
//import org.batatasframework.support.database.FieldMetadata;
//import org.batatasframework.support.database.sql.TableInstance;
//import org.batatasframework.support.database.sql.field.DefaultSelectFragment;
//import org.batatasframework.support.database.sql.field.SelectFragment;
//import org.batatasframework.support.database.sql.spi.TableCriterion;
//import org.batatasframework.support.definition.TableDefinition;
//import org.batatasframework.support.definition.TableDefinitionResource;
//import org.batatasframework.support.definition.impl.AbstractSingleFieldDefinition;
//
//public class AttributeFieldDefinition extends AbstractSingleFieldDefinition{
//
//	private final AttributeFieldMetadata fieldMetadata;
//	
//	public AttributeFieldDefinition(
//			TableDefinition tableDefinition, 
//			AttributeFieldMetadata fieldMetadata) {
//		super(fieldMetadata.getName(), tableDefinition);
//		
//		this.fieldMetadata = fieldMetadata;
//		this.format = fieldMetadata.getFormat();
//		this.title = fieldMetadata.getTitle();
//	}
//
//	@Override
//	public TableDefinitionResource getSourceTable() {
//		return this.tableDefinition;
//	}
//
//	@Override
//	public FieldMetadata getSourceField() {
//		return fieldMetadata;
//	}
//
//	@Override
//	public boolean contains(FieldMetadata fieldMetadata) {
//		return this.fieldMetadata == fieldMetadata;
//	}
//
//	@Override
//	public SelectFragment buildFragment(TableCriterion tableCriterion) throws Exception {
//		// TODO 这里不用使用自动生成的别名，而是使用原来定义的指标的名称
//		TableInstance tableSource = tableCriterion.safeLoadSource(tableCriterion, tableDefinition, true);
//		
//		DefaultSelectFragment selectFragment = tableCriterion.field(tableSource, fieldMetadata);
//		selectFragment.setFormat(getFormat());
//		selectFragment.setTitle(getTitle());
//		selectFragment.setGroup(getGroup());
//		return selectFragment;
//	}
//
//}
